#include "Graphics/IRenderTarget.h"
#include "Graphics/IViewport.h"

namespace tyro
{
	namespace Graphics
	{


		IRenderTarget::IRenderTarget()
		{

		}

		IRenderTarget::~IRenderTarget()
		{
			ViewportMap::iterator it = viewports.begin();
			while (it != viewports.end())
			{
				// Delete the viewport
				delete (*it++).second;
			}
		}

		tyro::UINT_32 IRenderTarget::GetHeight( void ) const
		{
			return height;
		}

		tyro::UINT_32 IRenderTarget::GetWidth( void ) const
		{
			return width;
		}

		tyro::UINT_32 IRenderTarget::GetColourDepth( void ) const
		{
			return colourDepth;
		}

		void IRenderTarget::Update( void )
		{
			ViewportMap::iterator it = viewports.begin();
			while (it != viewports.end())
			{
				// Update the viewport
				(*it++).second->Update();
			}
			
		}

		IViewport* IRenderTarget::AddViewport( Camera::Camera* cam, INT_32 ZOrder /*= 0*/, FLOAT_32 left /*= 0.0f*/, FLOAT_32 top /*= 0.0f */, FLOAT_32 width /*= 1.0f*/, FLOAT_32 height /*= 1.0f*/ )
		{

			IViewport* newViewport = new IViewport(cam,this, left, top, width, height);

			viewports.insert(ViewportMap::value_type(ZOrder, newViewport));

			return newViewport;
		}

	}
}